<template>
  <PageWrapper title="创建任务" contentBackground>
    <BasicForm @register="registerForm" class="pt-5" />
  </PageWrapper>
</template>
<script setup lang="ts">
  import PageWrapper from '@/components/Page/src/PageWrapper.vue';
  import ApiV1 from '@/views/common/operate/ApiV1';

  import BasicForm from '@/components/Form/src/BasicForm.vue';
  import { onMounted } from 'vue';
  import { addtopic } from '@/views/dp_platform/qiangua.api';
  import { useQianguaFormSchema } from '@/views/dp_platform/qiangua.data';

  const { registerForm, formMethods, methods } = ApiV1.usePageHandle({
    formProps: {
      schemas: useQianguaFormSchema(),
      fieldMapToTime: [['datetime', ['condition.start_date', 'condition.end_date'], 'YYYY-MM-DD']],
      baseColProps: { span: 8 },
      submitFunc: async () => {
        await methods.handleSubmit();
      },
    },
    saveFn: addtopic,
    title: '',
  });
  onMounted(() => {
    formMethods.updateSchema([
      { field: 'start_row', ifShow: false },
      { field: 'end_row', ifShow: false },
    ]);
    formMethods.setFieldsValue({ type: 2 });
  });
</script>
